package com.kim.logs.util;
/**
 * @Deacription TODO
 * @Author jianhua.hong
 * @Date 2020/4/3 10:39
 **/
public enum TimeCostEnum {
//    M1(0, 20, "M1"),
//    M2(20, 40, "M1"),
//    M3(40, 60, "M1"),
//    M4(60, 80, "M1"),
//    M5(80, 100, "M1"),
//    M6(100, 150, "M1"),
//    M7(150, 200, "M1"),
//    M8(200, 300, "M1"),
//    M9(300, 999999999, "M1"),
    M1(0, 1000, "正常"),
    M2(1000, 3000, "稍慢"),
    M3(3000, 5000, "缓慢"),
    M4(5000, 10000, "急需处理"),
    M5(10000, 99999, "崩溃接口"),
    ;
    private int beginValue;
    private int endValue;
    private String costMark;
    TimeCostEnum(int beginValue, int endValue, String costMark) {
        this.beginValue = beginValue;
        this.endValue = endValue;
        this.costMark = costMark;
    }
    public int getBeginValue() {
        return beginValue;
    }
    public int getEndValue() {
        return endValue;
    }
    private String getCostMark() {
        return costMark;
    }
    public static String costMark(long costTime) {
        String mark = "M0";
        for (TimeCostEnum timeCostEnum : TimeCostEnum.values()) {
            long beginValue = timeCostEnum.getBeginValue();
            long endValue = timeCostEnum.getEndValue();
            if (beginValue < costTime && costTime <= endValue) {
                mark = timeCostEnum.getCostMark();
                break;
            }
        }
        return mark;
    }
}